package com.aerospace.example.hello.util;

import com.aerospace.example.hello.service.GrpcService;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName ServiceLocator
 * @Description
 * @Author yuhang11
 * @Date 2021/12/7 7:12 下午
 * @Version 1.0
 */
@Component
public class ServiceLocator implements ApplicationContextAware {
    private Map<String, GrpcService> map;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        map = applicationContext.getBeansOfType(GrpcService.class);
    }

    public Map<String, GrpcService> getMap() {
        return map;
    }
}
